// 移除k个数字 402
// 比较最左 是否最大 大就要删除
var removeKdigists = function (num, k) {
    let stack = [];
    if (num.length == k) return "0";
    for (let val of num) {
        while (k && stack.length && stack[stack.length - 1] > val) {
            stack.pop();
            k--;
        }
        stack.push(val)
    }
    let res = stack.join("");
    if (res == 0) return "0";
    while (stack[0] == 0) {
        stack.shift()
    }
    return stack.join("").substring(0, stack.length - k);
}